#ifndef _CLIENT_
#define _CLIENT_

#include <SFML/Network.hpp>
#include "MessageQueue.hpp"
#include "Objects/Player.hpp"
#include "Scripting/Scriptable.hpp"

class Client: public Scriptable {
    friend class ClientCollection;
private:
    std::string saddress;
public:

	bool active;

    /** 
    * The index of this client in the ClientCollection array.
    */
    byte index;

    /** 
    * The address of this client.
    */
    sf::IpAddress address;

    /** 
    * The port the client is listening on.
    */
    unsigned short port;

    MessageQueue outQueue;

    /** 
    * Time since last message received from this client.
    */
    sf::Clock lastMessage;

	/** 
	* Client's name.
	*/
	std::string name;

	/** 
	* The client's player entity.
	*/
	Player entity;
    
	Client();
    void setup(std::string inName, const sf::IpAddress& inAddress, const unsigned short inPort);

    virtual void bind(lua_State* luaState);
    virtual void push(lua_State* luaState);

    ~Client();
};

#endif